<template>
  <a-modal
    dialogClass="cus-print"
    :title="title"
    :width="1000"
    :visible="visible"
    :maskClosable="false"
    switchFullscreen
    @cancel="handleCancel"
    v-drag
  >
    <div id="printContent">
      <div style="padding-top: 30px; text-align: center; font-size: 15px; font-weight: 500">
        <span v-if="state === 1">{{ $t('采购单详情') }}</span>
        <span v-if="state === 2">{{ $t('其他出库单详情') }}</span>
        <span v-if="state === 3||state === 7">{{ $t('调拨单详情') }}</span>
        <span v-if="state === 4">{{ $t('盘点单详情') }}</span>
        <span v-if="state === 5">{{ $t('返货单详情') }}</span>
        <span v-if="state === 6">{{ $t('其他入库单详情') }}</span>
      </div>
      <div style="margin-top: 4px">
        <span>{{ $t('订单号') }}：{{ dataForm.id }}&emsp;</span>
        <span v-if="state === 1 || state === 5 || state === 6">{{ $t('仓库') }}:{{ dataForm.store_dictText }}&emsp;</span>
        <span v-if="state === 2">{{ $t('仓库') }}:{{ dataForm.store_dictText }}&emsp;</span>
        <span v-if="state === 3||state === 7">
          {{ $t('调出仓库') }}:{{ dataForm.outStore_dictText }}&emsp;{{ $t('调入仓库')
          }}:{{ dataForm.inStore_dictText }}&emsp;</span
        >
        <span v-if="state === 4">{{ $t('仓库') }}:{{ dataForm.store_dictText }}&emsp;</span>
        <span v-if="state !== 4">{{ $t('业务时间') }}:{{dataForm.state==1?dataForm.auditTime:dataForm.createTime}}</span>
      </div>
      <div>
        <span>{{ $t('操作员') }}:{{ nickname() }}</span>
        <span>&emsp;{{ $t('打印时间') }}:{{ printTime }}</span>
      </div>
      <div>
        <a-table
          :columns="columns"
          :dataSource="dataSource"
          size="middle"
          bordered
          class="j-table-force-nowrap"
          :pagination="false"
          :customRow="customRow"
        >
        </a-table>
      </div>
      <div style="margin-top: 6px; font-weight: bolder">
        <span v-if="state === 1 || state === 2 || state === 3 || state === 7 || state === 5 || state === 6"
          >{{ $t('总数量') }}:{{ totalNum }} &nbsp;
        </span>
        <span v-if="state === 1 || state === 2 || state === 3|| state === 7 || state === 5 || state === 6"
          >{{ $t('总金额') }}:{{ totalAmo }} &nbsp;
        </span>
        <span v-if="state === 2">{{ $t('出库类型') }}:{{ dataForm.outType_dictText }} &nbsp; </span>
        <span>{{ $t('备注') }}:{{ dataForm.comment }}</span>
      </div>
    </div>
    <template slot="footer">
      <a-button type="primary" v-print="'#printContent'">{{ $t('打印') }}</a-button>
      <a-button @click="handleCancel">{{ $t('关闭') }}</a-button>
    </template>
  </a-modal>
</template>

<script>
import moment from 'moment'
import { getAction } from '@/api/manage'
import { mapGetters } from 'vuex'
export default {
  name: 'GoodsPrintModal',
  components: {},
  data() {
    return {
      title: this.$t('详情'),
      width: 800,
      visible: false,
      dataForm: {},
      dataSource: [],
      columns: [],
      columns1: [
        {
          title: this.$t('序号'),
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          width: 36,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: this.$t('商品编码'),
          dataIndex: 'goodsCode',
          align: 'center',
          width: 61,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('商品名称'),
          dataIndex: 'goodsId_dictText',
          align: 'center',
          width: 170,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },{
          title: this.$t('供应商'),
          dataIndex: 'supplier_dictText',
          align: 'center',
          width: 90,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('单位'),
          key: 'unit_dictText',
          dataIndex: 'unit_dictText',
          align: 'center',
          width: 50,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('规格'),
          key: 'standard',
          dataIndex: 'standard',
          align: 'center',
          width: 80,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('采购数量'),
          key: 'number',
          dataIndex: 'number',
          align: 'center',
          width: 36,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('单价'),
          key: 'unitPrice',
          dataIndex: 'unitPrice',
          align: 'center',
          width: 60,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('总金额'),
          key: 'totalAmount',
          dataIndex: 'totalAmount',
          align: 'center',
          width: 76,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('业务前库存'),
          key: 'beforeNum',
          dataIndex: 'beforeNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('业务后库存'),
          key: 'afterNum',
          dataIndex: 'afterNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('备注'),
          key: 'comement',
          dataIndex: 'comement',
          align: 'center',
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
      ],
      columns2: [
        {
          title: this.$t('序号'),
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          width: 36,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: this.$t('商品编码'),
          dataIndex: 'goodsCode',
          align: 'center',
          width: 61,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('商品名称'),
          dataIndex: 'goodsId_dictText',
          align: 'center',
          width: 170,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('出库数量'),
          key: 'number',
          dataIndex: 'number',
          align: 'center',
          width: 36,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('成本'),
          key: 'unitPrice',
          dataIndex: 'unitPrice',
          align: 'center',
          width: 70,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('总成本'),
          key: 'totalAmount',
          dataIndex: 'totalAmount',
          align: 'center',
          width: 80,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('单位'),
          key: 'unit_dictText',
          dataIndex: 'unit_dictText',
          align: 'center',
          width: 50,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('规格'),
          key: 'standard',
          dataIndex: 'standard',
          align: 'center',
          width: 80,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('业务前库存'),
          key: 'beforeNum',
          dataIndex: 'beforeNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('业务后库存'),
          key: 'afterNum',
          dataIndex: 'afterNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('备注'),
          key: 'comment',
          dataIndex: 'comment',
          align: 'center',
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
      ],
      columns3: [
        {
          title: this.$t('序号'),
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          width: 36,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: this.$t('商品编码'),
          dataIndex: 'goodsCode',
          align: 'center',
          width: 61,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('商品名称'),
          dataIndex: 'goodsId_dictText',
          align: 'center',
          width: 170,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('成本'),
          key: 'unitPrice',
          dataIndex: 'unitPrice',
          align: 'center',
          width: 70,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('调拨数量'),
          key: 'number',
          dataIndex: 'number',
          align: 'center',
          width: 36,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('总金额'),
          key: 'totalAmount',
          dataIndex: 'totalAmount',
          align: 'center',
          width: 80,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('单位'),
          key: 'unit_dictText',
          dataIndex: 'unit_dictText',
          align: 'center',
          width: 50,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('规格'),
          key: 'standard',
          dataIndex: 'standard',
          align: 'center',
          width: 80,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('业务前库存'),
          key: 'beforeNum',
          dataIndex: 'beforeNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('业务后库存'),
          key: 'afterNum',
          dataIndex: 'afterNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('备注'),
          key: 'comment',
          dataIndex: 'comment',
          align: 'center',
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
      ],
      columns4: [
        {
          title: this.$t('序号'),
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          width: 36,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: this.$t('商品编码'),
          dataIndex: 'goodsCode',
          align: 'center',
          width: 70,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('商品名称'),
          dataIndex: 'goodsId_dictText',
          align: 'center',
          width: 200,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('成本'),
          key: 'unitPrice',
          dataIndex: 'unitPrice',
          align: 'center',
          width: 64,
          customRender: (t, r) => {
            if (!t) {
              return '0.00'
            }
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('系统数量'),
          key: 'systemStock',
          dataIndex: 'systemStock',
          align: 'center',
          width: 46,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customHeaderCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('系统金额'),
          key: 'systemAmount',
          dataIndex: 'systemAmount',
          align: 'center',
          width: 64,
          customRender: (t, r) => {
            if (!t) {
              return '0.00'
            }
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('实盘数量'),
          key: 'actualStock',
          dataIndex: 'actualStock',
          align: 'center',
          width: 46,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customHeaderCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('实盘金额'),
          key: 'actualAmount',
          dataIndex: 'actualAmount',
          align: 'center',
          width: 64,
          customRender: (t, r) => {
            if (!t) {
              return '0.00'
            }
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('差异'),
          key: 'error',
          dataIndex: 'error',
          align: 'center',
          width: 64,
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('差异金额'),
          key: 'errorAmount',
          dataIndex: 'errorAmount',
          align: 'center',
          width: 64,
          customRender: (t, r) => {
            if (!t) {
              return '0.00'
            }
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('备注'),
          key: 'comment',
          dataIndex: 'comment',
          align: 'center',
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
      ],
      columns5: [
        {
          title: this.$t('序号'),
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          width: 36,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: this.$t('商品编码'),
          dataIndex: 'goodsCode',
          align: 'center',
          width: 61,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('商品名称'),
          dataIndex: 'goodsId_dictText',
          align: 'center',
          width: 170,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('返货数量'),
          key: 'number',
          dataIndex: 'number',
          align: 'center',
          width: 36,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('单价'),
          key: 'unitPrice',
          dataIndex: 'unitPrice',
          align: 'center',
          width: 70,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('总金额'),
          key: 'totalAmount',
          dataIndex: 'totalAmount',
          align: 'center',
          width: 80,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('单位'),
          key: 'unit_dictText',
          dataIndex: 'unit_dictText',
          align: 'center',
          width: 50,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('规格'),
          key: 'standard',
          dataIndex: 'standard',
          align: 'center',
          width: 80,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('业务前库存'),
          key: 'beforeNum',
          dataIndex: 'beforeNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('业务后库存'),
          key: 'afterNum',
          dataIndex: 'afterNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('备注'),
          key: 'comement',
          dataIndex: 'comement',
          align: 'center',
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
      ],
      columns6: [
        {
          title: this.$t('序号'),
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          width: 36,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: this.$t('商品编码'),
          dataIndex: 'goodsCode',
          align: 'center',
          width: 61,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('商品名称'),
          dataIndex: 'goodsId_dictText',
          align: 'center',
          width: 170,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('单位'),
          key: 'unit_dictText',
          dataIndex: 'unit_dictText',
          align: 'center',
          width: 50,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('规格'),
          key: 'standard',
          dataIndex: 'standard',
          align: 'center',
          width: 80,
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('入库数量'),
          key: 'number',
          dataIndex: 'number',
          align: 'center',
          width: 36,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('成本'),
          key: 'unitPrice',
          dataIndex: 'unitPrice',
          align: 'center',
          width: 70,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('总金额'),
          key: 'totalAmount',
          dataIndex: 'totalAmount',
          align: 'center',
          width: 80,
          customRender: (t, r) => {
            return t.toFixed(2)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('业务前库存'),
          key: 'beforeNum',
          dataIndex: 'beforeNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('业务后库存'),
          key: 'afterNum',
          dataIndex: 'afterNum',
          align: 'center',
          width: 50,
          customRender: (t, r) => {
            return t.toFixed(0)
          },
          customCell: function (record, rowIndex) {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customHeaderCell: function (record, rowIndex) {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
        {
          title: this.$t('备注'),
          key: 'comement',
          dataIndex: 'comement',
          align: 'center',
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
              },
            }
          },
        },
      ],
      totalNum: 0,
      totalAmo: 0,
      state: '',
      printTime: '',
    }
  },
  created() {},
  methods: {
    ...mapGetters(['nickname']),
    show(record, state) {
      this.visible = true
      this.printTime = moment().format('YYYY-MM-DD HH:mm:ss')
      this.state = state
      if (this.state === 1) {
        this.columns = this.columns1
      }
      if (this.state === 2) {
        this.columns = this.columns2
      }
      if (this.state === 3||this.state === 7) {
        this.columns = this.columns3
      }
      if (this.state === 4) {
        this.columns = this.columns4
      }
      if (this.state === 5) {
        this.columns = this.columns5
      }
      if (this.state === 6) {
        this.columns = this.columns6
      }
      this.totalAmo = 0
      this.totalNum = 0
      this.dataForm = Object.assign({}, record)
      let url = ''
      if (this.state === 1 || this.state === 6) {
        url = '/goods/bisGoodsInstock/queryBisGoodsInstockDetailsByMainId'
      }
      if (this.state === 2) {
        url = '/goods/bisGoodsOutstock/queryBisGoodsOutstockDetailsByMainId'
      }
      if (this.state === 3) {
        url = '/goods/bisGoodsTransfer/queryBisGoodsTransferDetailsByMainId'
      }
      if (this.state === 4) {
        url = '/goods/bisGoodsInventory/queryBisGoodsInventoryDetailsByMainId'
      }
      if (this.state === 5) {
        url = '/goods/bisGoodsBack/queryBisGoodsBackDetailsByMainId'
      }
      if (this.state === 7) {
        url = '/goods/bisGoodsInterTransfer/queryDetailsByMainId'
      }
      getAction(url, { id: record.id }).then((res) => {
        if (res.success) {
          this.dataSource = res.result
          if (this.state == 4) {
            let total = {
              goodsId_dictText: this.$t('合计'),
              unitPrice: 0,
              systemAmount: 0,
              systemStock: 0,
              actualStock: 0,
              actualAmount: 0,
              errorAmount: 0,
              error: 0,
            }
            this.dataSource.forEach((col) => {
              total.unitPrice += col.unitPrice
              total.systemAmount += col.systemAmount
              total.systemStock += col.systemStock
              total.actualStock += col.actualStock
              total.actualAmount += col.actualAmount
              total.errorAmount += col.errorAmount
              total.error += col.error
            })
            this.dataSource.push(total)
          }
          if (this.state === 1 || this.state === 2 || this.state === 3 || this.state === 5 || this.state === 6) {
            this.dataSource.forEach((col) => {
              this.totalNum += col.number
              this.totalAmo += col.totalAmount
            })
            this.totalNum = this.totalNum.toFixed(0)
            this.totalAmo = this.totalAmo.toFixed(2)
          }
        }
      })
    },
    handleCancel() {
      this.close()
    },
    close() {
      this.visible = false
    },
    customRow(r, i) {
      return {
        style: {
          fontWeight: r.goodsId ? 400 : 700,
        },
      }
    },
  },
}
</script>

<style>
</style>